/*
 * 文件名：LuceneMain.java	 
 * 时     间：下午10:49:57
 * 作     者：Administrator       
 * 版     权： 2012-2022 湖南智软网络科技, 公司保留所有权利.
 * 联     系：http://www.073586.com/
 */
package com.zbc.lucene.util;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

import org.apache.lucene.document.Document;
import org.apache.lucene.index.IndexWriter;

import com.index.entity.Page;
import com.local.model.CarParkOutCopy;
import com.local.page.CarInAndOutPageInfo;

/**
 * 类描述:这里是类描述
 * 
 * @ClassName: LuceneMain
 * @author Administrator
 * @date 2016年8月8日 下午10:49:57
 */
public class LuceneMain
{
	public static void main(String[] args) throws Exception
	{
		String carNo = "粤B465J7";
		String carInUuid = "dsdw5552dsfsdf";
		String indexPath = "D:/index/testa";
		
		IndexWriter writer = IndexUtil.getIndexWriter(indexPath, true);
		Map<FieldEnum, Object> map = new HashMap<FieldEnum, Object>();
		map.put(FieldEnum.STRING_FIELD, carInUuid);
		map.put(FieldEnum.CONTENTS, carNo);
		IndexUtil.indexDoc(writer, Arrays.asList(map));
		
		CarInAndOutPageInfo<CarParkOutCopy> page = new CarInAndOutPageInfo<CarParkOutCopy>();
		page.setCarNo("粤B465J7");
		page.setCurrentPage(1);
		page.setPageSize(10);
		Page<Document> docPage = SearchUtil.pageQueryIndex(indexPath, page);
		if (docPage != null && docPage.getList() != null
				&& docPage.getList().size() > 0)
		{
			System.out.println(docPage.getList().get(0));
		}
		
		IndexUtil.closeWriter();
	}
}
